package com.wang.interview;

import java.io.IOException;

import javax.servlet.AsyncContext;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class AsyncServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
		// 开启Tomcat异步Servlet支持
		req.setAttribute("org.apache.catalina.ASYNC_SUPPORTED", true);
		
		final AsyncContext  asynCtx = req.getAsyncContext();
		asynCtx.start(new Runnable(){
			@Override
			public void run() {
				// 在此处添加异步处理的代码			
				asynCtx.complete();
			}
		});
		
		
		ServletConfig config = getServletConfig();
		config.getInitParameter("");
		
	}
	
}
